package a_13届蓝桥真题;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class d最少刷题数 {
	public static void main(String[] args) {
		d最少刷题数 test = new d最少刷题数();
		test.useDeal();
	}
	
	public void useDeal() {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scanner.nextInt();
		}
		dealOther(arr, N);
	}
	
	public void dealOther(int[] arr, int N) {
		int[] clone = arr.clone();
		int median[] = new int[2];
		int mid = (N - 1) / 2;
		Arrays.sort(clone);
		int l = 0;
		int r = N - 1;
		while (l < r) {
			int mid1 = (l + r) >>> 1;
			if (clone[mid1] >= clone[mid]) {
				r = mid1;
			} else {
				l = mid1 + 1;
			}
		}
		median[0] = l;
		l = 0;
		r = N - 1;
		while (l < r) {
			int mid2 = (l + r + 1) >>> 1;//+1防卡死
			if (clone[mid2] <= clone[mid]) {
				l = mid2;
			} else {
				r = mid2 - 1;
			}
		}
		median[1] = r;
		int small = median[0];
		int big = N - 1 - median[1];
		int midValue = clone[mid];
		for (int i = 0; i < N; i++) {
			if (arr[i] > midValue) {
				System.out.print(0 + " ");
			} else if (arr[i] == midValue) {
				if (big <= small) {
					System.out.print(0 + " ");
				} else {
					System.out.print(1 + " ");
				}
			} else {
				if (big < small) {
					System.out.print((midValue - arr[i]) + " ");
				} else {
					System.out.print((midValue + 1 - arr[i]) + " ");
				}
			}
		}
	}
	
	public void dealSimple(int[] arr, int N) {
		int[] mid = new int[2];
		int[] helper = arr.clone();
		quickSortThree(helper, 0, N - 1);
		mid = partitionThree(helper, 0, N - 1);
//		System.out.println(mid[0] + " " + mid[1]);
		int median = helper[mid[1]];
		int big = N - 1 - mid[1];
		int small = mid[0];
		for (int i = 0; i < N; i++) {
//			if (i == N - 1) {
//				
//			}
			if (arr[i] > median) {
				System.out.print(0 + " ");
			} else if (arr[i] == median) {
				if (big <= small) {
					System.out.print(0 + " ");
				} else {
					System.out.print(1 + " ");
				}
			} else if (arr[i] < median) {
				if (big < small) {
					System.out.print((median - arr[i]) + " ");
				} else {
					System.out.print((median + 1 - arr[i]) + " ");
				}
			}
		}
	}
	
	public void deal(int[] arr, int N) {
		int[] mid = new int[2];
		int[] helper = arr.clone();
		quickSortThree(helper, 0, N - 1);
		for (int i = 0; i < N; i++) {
			if (arr[i] > helper[mid[1]]) {
				System.out.print(0 + " ");
			} else if (arr[i] == helper[mid[1]]) {
				if (N - 1 - mid[1] <= mid[0]) {
					System.out.println(0 + " ");
				} else {
					System.out.println((helper[mid[1]] + 1 - arr[i]) + " ");
				}
			} else if (arr[i] < helper[mid[1]]) {
				if (N - 1 - mid[1] < mid[0]) {
					System.out.println((helper[mid[1]] - arr[i]) + " ");
				} else {
					System.out.println((helper[mid[1]] + 1 - arr[i]) + " ");
				}
			}
		}
	}
	
	public void quickSortThree(int[] arr, int p, int r) {
		if (p < r) {
			if (r - p + 1 <= 8) {
				insertSort(arr, p, r);
			} else {
				int[] q = partitionThree(arr, p, r);
				quickSortThree(arr, p, q[0] - 1);
				quickSortThree(arr, q[1] + 1, r);
			}
		}
		
	}
	
	public int[] partitionThree(int[] arr, int p, int r) {
		int e = p + 1;
		int sp = p + 1;
		int bigger = r;
		int midIndex = getMedian(arr, p, r);
		swap(arr, p, midIndex);
		int piovet = arr[p];
		int[] equalNumber = new int[2];
		while (sp <= bigger) {
			while (sp <= bigger && arr[sp] <= piovet) {
				if (arr[sp] < piovet && sp == e) {
					sp++;
					e++;
				} else if (arr[sp] < piovet && sp != e) {
					swap(arr, e, sp);
					sp++;
					e++;
				} else {
					sp++;
				}
			}
			while (sp <= bigger && arr[bigger] > piovet) {
				bigger--;
			}
			if (sp < bigger) {
				swap(arr, sp, bigger);
			}
		}
		swap(arr, p, e - 1);
		equalNumber[0] = e - 1;
		equalNumber[1] = bigger;
		return equalNumber;
	}
	
	public int getMedian(int[] arr, int p, int r) {
		int size = r - p + 1;
		int groupSize = (size % 5 == 0) ? (size / 5) : ((size / 5) + 1);
		int indexOfMedians = 0;
		int[] medians = new int[groupSize];
		HashMap<Integer, Integer> medainsValueIndex = new HashMap<Integer, Integer>();
		for (int i = 0; i < groupSize; i++) {
			if (i == groupSize - 1) {
				insertSort(arr, p + i * 5, r);
				medians[indexOfMedians++] = arr[(p + i * 5 + r) >>> 1];
				medainsValueIndex.put(arr[(p + i * 5 + r) >>> 1], (p + i * 5 + r) >>> 1);
			} else {
				insertSort(arr, p + i * 5, p + i * 5 + 4);
				medians[indexOfMedians++] = arr[p + i * 5 + 2];
				medainsValueIndex.put(arr[p + i * 5 + 2], p + i * 5 + 2);
			}
		}
		insertSort(medians, 0, groupSize - 1);
		return medainsValueIndex.get(medians[(groupSize - 1) >>> 1]);
	}
	
	public void insertSort(int[] arr, int p, int r) {
		int brfore_i = 0;
		int value_i = 0;
		for (int i = p + 1; i <= r; i++) {
			brfore_i = i - 1;
			value_i = arr[i];
			while (brfore_i > p - 1 && arr[brfore_i] > value_i) {
				arr[brfore_i + 1] = arr[brfore_i--];
			}
			arr[brfore_i + 1] = value_i;
		}
	}
	
	public void swap(int[] arr, int x, int y) {
		int temp = arr[x];
		arr[x] = arr[y];
		arr[y] = temp;
	}
}
